<template>
	<view class="p-50 p-t-30 left" style="width: 650rpx;">
		<text class="ts-50 tb wa left m-b-50">
			<text class="tc-green">{{['', '预警警告', '平台通知', '订单通知', '续费通知'][type]}}</text>
		</text>
		<view>
			<view v-if="!isEmpty">
				<view v-for="item in noticeList" :key="item.id" class="ts-30 wa left m-t-30 ju-list" :class="index === noticeList.length-1 ? 'm-b-50' : ''">
					<text class="wa left m-b-20">
						<text class="ts-32 tb tc-green left">{{item.title || ''}}</text>
						<text class="tc-gray right ts-26">{{item.createtime || ''}}</text>
					</text>
					<text class="wa left tc-gray m-b-30 ts-26">{{item.content || ''}}</text>
				</view>
			</view>
			<view v-if="!isLoading && isEmpty">
				<xy-empty text="暂无记录" :imgsrc="'notice'" />
			</view>
		</view>
	</view>
</template>

<script>
	import xyEmpty from '@/components/xy-empty';
	export default {
		components: {
			xyEmpty
		},
		data() {
			return {
				css:{},
				search:'',
				isEmpty: true,
				noticeList: [],
				currentPage: 1,
				isLoading:true,
				lastPage: 1,
				type: 1,
				loadStatus: 'loadmore',
			}
		},
		onLoad(options) {
			this.type = options.type ? options.type : '1'
			this.$xyfun.setNavBar(' ');
			this.css = this.$xyfun.css();
			this.loadData();
		},
		
		onPullDownRefresh() {
			this.currentPage = 1;
			this.noticeList = [];
			this.loadData();
		},
		methods: {
			loadData(){
				this.$api.get({
					url: '/user/user/typeMessage',
					loadingTip:'加载中...',
					data: {
						page: this.currentPage,
						type: this.type
					},
					success: res => {
						uni.stopPullDownRefresh();
						this.noticeList = [...this.noticeList, ...res.data];
						this.isEmpty = !this.noticeList.length;
						this.isLoading = false;
						this.currentPage = res.current_page; 
						this.lastPage = res.last_page;
						this.loadStatus = this.currentPage < res.last_page ? 'loadmore' : 'nomore';
					}
				});
			},
			
		}
	}
</script>

<style scoped lang="scss">
	.ju-list {
		border-bottom: 1rpx solid #dcdada;
	}
</style>
